package com.example.r2022913.exception;

/**
 * 描述：     统一异常
 */
public class SelfException extends RuntimeException {

    //状态码
    private final Integer code;
    //信息
    private final String message;

    //两参构造 把传来的code和message赋值
    public SelfException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    //接受枚举 调用两参构造
    public SelfException(ExceptionEnum exceptionEnum) {

        this(exceptionEnum.getCode(), exceptionEnum.getMsg());
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
